import {ADD_TOCART,ADD_COUNTER} from "./FuncName";
export default {
    addCart(context,payLoad){
        return new Promise((resolve)=>{
            let oldProduct =context.state.cartList.find(item => item.iid===payLoad.iid)
            if(oldProduct){
                context.commit(ADD_TOCART,oldProduct)
                resolve('商品数量加一')
            }else {
                payLoad.count=1
                context.commit(ADD_COUNTER,payLoad)
                resolve('添加到购物车成功!')
            }
        })
    }
}
